Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signer: Fix loading of per-signature private keys with different types #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dev-aaront-org
Copy link

If a Signature object's Key or KeyFile property is set to a non-ref, Signer assumes it is a file path and attempts to load the private key from it, but it may use the wrong key type, which will cause the signature to fail. Currently Signer looks at $self->{Algorithm} to determine the key type, and this changes it to look at the Signature's algorithm instead.

I'm not entirely sure this fix is right or necessary because it doesn't really look like a supported use case. The docs for Signature say that Key should be an object, and KeyFile is not used at all within Signature. So I was also considering just removing the key loading from Signer and making it the user's responsibility to load their own keys if they're creating their own Signatures. But that would be a backward-incompatible change.

Anyway, I'm certainly open to suggestions if you prefer a different fix.

This keeps the key type determination logic in one place.
If the key file comes from the Signature object, use the algorithm of
that Signature object to determine the key type.
The Signature constructor does not make use of the KeyFile property.
@dev-aaront-org
Copy link
Author

dev-aaront-org commented Nov 17, 2024

I was thinking about this some more and I realized that my fix enabled some nonsense scenarios where the key file could come from Signer but the key type from Signature, so I've tweaked it a bit. Now, if the key file comes from $signature, then the key type comes from $signature->algorithm. And likewise, if the key file comes from $self, the key type comes from $self->{Algorithm}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant